﻿<div ms-controller="W_KCGL">
    <!-- 添加按钮 -->
    <div class="btn-add">
        <button type="button" class="btn btn-info btn-lg" ms-click="AddView('KCGL_KJGL')"><i class="iconfont icon-jiahao ft12 mr5"></i>添加课件</button>
    </div>
    <!-- 按条件选择 -->
    <div class="tab-filter-type">
        <div class="oh">
            <h5 class="pull-left tr">课件分类：</h5>
            <ul class="tab-type ft14">
                <li ms-click="SelectType('')"><span ms-class-1="active:lbType==''">全部</span></li>
                <li ms-click="SelectType(1)"><span ms-class="active:lbType==1">视频</span></li>
                <li ms-click="SelectType(2)"><span ms-class="active:lbType==2">文档</span></li>
            </ul>
        </div>
        <!-- 搜索 -->
        <div class="oh">
            <div class="input-group ml15" style="width:295px;">
                <input type="search" class="form-control" ms-duplex="search.searchcontent" placeholder="搜索课件名称">
                <span class="input-group-addon" ms-click="GetLIST()">搜索</span>
            </div>
        </div>
    </div>
    <!-- 展开更多选项 -->
    <div class="add-tab ft14 tc mt20" style="display:none;">
        <span>更多筛选<i class="caret"></i></span>
    </div>
    <!-- 按条件选择 -->
    <!-- 表格 -->
    <div class="default-tab ft14 pt20 hover-btn">
        <table class="table table-striped table-responsive table-hover">
            <thead>
                <tr>
                    <th class="tc">序号</th>
                    <th>
                        课件分类
                    </th>
                    <th>课件名称</th>
                    <th>主讲人</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <tr ms-repeat-el="ListData">
                    <td class="tc">
                        {{$index+1+page.pagecount*(page.pageindex-1)}}
                    </td>
                    <td>{{GetTypeName(el.KJType)}}</td>
                    <td>{{el.KJName}}</td>
                    <td>{{el.KJZJR}}</td>
                    <td>
                        <span class="btn-click">
                            <a class="cz-btn ft18 bj-color tip" data-toggle="tooltip" title="编辑" ms-click="AddView('KCGL_KJGL','课件编辑',el.ID,$event)">
                                <i class="iconfont icon-bianji"></i>
                            </a>
                            <a class="cz-btn ft18 sc-color tip" data-toggle="tooltip" title="删除" ms-click="DELKCGL(el,event)">
                                <i class="iconfont icon-shanchu"></i>
                            </a>
                        </span>
                    </td>
                </tr>

            </tbody>
            <tfoot>
                <tr ms-if="isnull"><td class="tc"></td><td>暂无数据</td></tr>
            </tfoot>
        </table>
        <div class="ui-datatable-page ft14 pl20">

            <div id="pageDiv" ms-visible="model.page.total>model.pageNum[0].num" class="pull-right"></div>
            <div class="pull-right" ms-visible="ListData.size()!=0">
                <span>共{{model.page.total}}条记录</span>
                <span ms-visible="model.page.total>model.pageNum[0].num">
                    选择每页条数
                    <select style="height: 25px; width: 50px;" ms-change="selNum(this.value)" ms-duplex="model.page.pagecount">
                        <option ms-repeat-pg="pageNum" ms-attr-value="pg.num" ms-attr-selected="pg.num==model.page.pagecount?'selected':''">{{pg.num}}</option>
                    </select>
                </span>
            </div>

        </div>
    </div>


</div>

<script>
    var tempindex = avalon.define({
        $id: "W_KCGL",
        kcflData: [],
        lbType: "",
        InitWigetData: function (str) {
            tempindex.GetLIST();

        },
        SelectType: function (type) {
            tempindex.lbType = type;
            tempindex.GetLIST();
        },
        GetLIST: function () {
            $.getJSON('/API/VIEWAPI.ashx?Action=KCGL_GETPXKJLIST', { p: 1, P1: tempindex.lbType, Content: model.search.searchcontent, pagecount: model.page.pagecount }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    model.ListData = resultData.Result;
                    model.page.total = resultData.Result1;
                    if (model.ListData.size() == 0) { model.isnull = true; } else { model.isnull = false; }
                    laypage({
                        cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                        pages: Math.ceil(parseInt(resultData.Result1) * 1.0 / model.page.pagecount), //通过后台拿到的总页数
                        curr: 1, //初始化当前页
                        skin: 'molv',
                        jump: function (e) { //触发分页后的回调
                            if (e.curr != model.page.pageindex) {
                                $.getJSON('/API/VIEWAPI.ashx?Action=KCGL_GETPXKJLIST', { p: e.curr, P1: tempindex.lbType, Content: model.search.searchcontent, pagecount: model.page.pagecount }, function (resultData) {
                                    if (resultData.ErrorMsg == "") {
                                        model.ListData = resultData.Result;
                                    }
                                })
                                model.page.pageindex = e.curr;
                            }
                        }
                    });
                }
            })
        },
        DELKCGL: function (item, event) {
            if (event) {
                event.stopPropagation();
            }
            top.ComFunJS.winconfirm("确认要删除此课件吗", function () {
                $.post('/API/VIEWAPI.ashx?Action=KCGL_DELKJGLBYID', { "P1": item.ID }, function (result) {
                    result = JSON.parse(result)
                    if (result.ErrorMsg == "") {
                        ComFunJS.winsuccess("删除成功");
                        model.ListData.remove(item);
                    } else {
                        ComFunJS.winwarning(result.ErrorMsg);
                    }
                })
            }, function () { })
        },
        GetTypeName: function (str) {
            var strName = "";
            switch (str) {
                case "1":
                    strName = "视频";
                    break;
                case "2":
                    strName = "文档";
                    break;
            }
            return strName;

        }
    })//@ sourceURL=KCGLLSIT.js;


</script>
